﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Medical_Store_Billing.Data_Access_Layer;
using Medical_Store_Billing.Object_Class;
using System.Windows.Forms;

namespace Medical_Store_Billing.Business_Login_Layer
{
    class DathangBLL
    {
        DathangDAL m_dathangdal = new DathangDAL();
        Dathangclass m_dathangclass;
        chitietdathangclass m_chitiet;

        public int Demdathang()
        {
            DataRow r = m_dathangdal.Demdathang().Rows[0];
            return Int32.Parse(r[0].ToString());
        }
        public DataTable Laychitiet(String name)
        {
            return m_dathangdal.Laychitiet(name);
        }
        public DataTable Timdathang(String name)
        {
            return m_dathangdal.Timdathang(name);
        }

        public bool Themdathang(String madondat, String ngay, String makh, String manv)
        {
            try
            {
                m_dathangclass = new Dathangclass();

                m_dathangclass.madondat = madondat;
                m_dathangclass.ngay = Convert.ToDateTime(ngay);
                m_dathangclass.makh = makh;
                m_dathangclass.manv = manv;

                return m_dathangdal.Themdathang(m_dathangclass);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
        }

        public bool Themchitietdathang(String madathang, String mahang, int soluong)
        {
            try
            {
                m_chitiet = new chitietdathangclass();

                m_chitiet.madondat = madathang;
                m_chitiet.mahang = mahang;
                m_chitiet.soluong = soluong;


                return m_dathangdal.Themchitietdathang(m_chitiet);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
        }

        public DataTable Laydsdathang()
        {
            return m_dathangdal.LayDSdathang();
        }
        public bool Suadathang(String madathang)
        {
            return m_dathangdal.Suadathang(madathang);
        }

    }
}
